The Essence of the Visitor Pattern
نویسندگان
چکیده
For object-oriented programming, the Visitor pattern enables the definition of a new operation on an object structure without changing the classes of the objects. The price has been that the set of classes must be fixed in advance, and they must each have a so-called accept method. In this paper we demonstrate how to program visitors without relying on accept methods and without knowing all classes of the objects in advance. The idea, derived from related work on shape polymorphism in functional programming, is to separate (1) accessing subobjects, and (2) acting on them. In the object-oriented setting, reflection techniques support access to sub-objects, as demonstrated in our Java class, Walkabout. It supports all visitors as subclasses, and they can be programmed without any further use of reflection. Thus a program using the Visitor pattern can now be understood as a specialized version of a program using the Walkabout class.
منابع مشابه
The Essence of the Visitor
For object-oriented programming, the Visitor pattern enables the deenition of a new operation on an object structure without changing the classes of the objects. The price has been that the set of classes must be xed in advance, and they must each have a so-called accept method. In this paper we demonstrate how to program visitors without relying on accept methods and without knowing all classe...
متن کاملبررسی تاثیر مراحل فنولوژیک بر روی درصد و ترکیبات شیمیایی اسانس گیاه مرتعی Satureja hortensis L.
Background : Summer savory is an annual grass plant, with a branched stem with the length of 10 to 30 cm that is distinguishable from the similar species due to having grayish green appearance and its leaves are narrow and long. In recent years, the anti-viral, anti-inflammatory, antibacterial, antifungal, antispasmodic, stomach invigorator and digestion facilitator characteristics of this spec...
متن کاملAuto-generation of Model Visitor Frameworks
The visitor pattern, a well known Gang of Four design pattern, provides a suitable way to add operational behaviour to models. However, as soon as the number of metamodels and visitor implementations start to grow, some of the pattern shortcomings make its usage less convenient. This paper presents how the synergy between the Visitor pattern and MDE has been addressed by two open source project...
متن کاملThe Language of the Visitor Design Pattern
Design patterns have been developed to cope with the vast space of possible different designs within object-oriented systems. One of those classic patterns is the Visitor Pattern that is used for representing an operation to be performed on the elements of an object structure. We present a mapping from the Visitor Pattern to a grammar that defines the set of visit sequences that can be performe...
متن کاملVisitor-Oriented Programming
Multiple dispatching and the visitor pattern are approaches to making object-oriented programs more extensible. Both have a flavor of pattern matching, thereby moving objectoriented programming closer to functional programming. The key idea of these approaches can be crystallized as a notion of visitor which lies between functions and objects. Can this idea be developed into a new form of visit...
متن کاملذخیره در منابع من
با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید
عنوان ژورنال:
دوره شماره
صفحات -
تاریخ انتشار 1998